<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta charset="utf-8">
  <title></title>
  <meta name="keywords" content="">
  <meta name="description" content="">
  <meta name="author" content="">
  <link href="css/daterangepicker.min.css" rel="stylesheet">
  <link rel="stylesheet" href="css/main.css">
  <link rel="stylesheet" href="css/lcommon.css">
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <!--[if lt IE 9]>
	<script src="js/html5shiv.min.js"></script>
	<script src="js/respond.min.js"></script>
<![endif]-->
  <meta name="renderer" content="webkit">
  <link rel="shortcut icon" href="favicon.ico">
  <style>
     #container {
      width: 100%;
      height: 260px;
    }
  </style>
</head>

<body>
  <div id="app" v-cloak>
    <header id="header"></header>
    <div class="header-space"></div>

    <div class="commonHeight" v-loading="loading">
      <template v-if="recruit">
        <section class="section71">
          <div class="content">
            <div class="left">
              <h3><b>{{recruit.name}}</b><span class="e2">{{recruit.salary_min}}-{{recruit.salary_max}}K</span></h3>
              <p>{{recruit.educationName}} | {{getNatureName()}} |
                {{recruit.experienceConfigName.max==0? recruit.experienceConfigName.min + "年以上" : recruit.experienceConfigName.min==0? recruit.experienceConfigName.max + "年以下" : (recruit.experienceConfigName.min+"-"+recruit.experienceConfigName.max+"年") }} |
                招{{recruit.num}}人
              </p>
              <p v-if="recruit.recruit_welfare">
                <span v-for="(tag, k) in recruit.recruit_welfare" :key="k" class="tag">{{tag.welfareName}}</span>
              </p>
              <p><time>{{recruit.createdFrom}}</time></p>
            </div>
            <div class="right">
              <a href="javascript:void(0)" @click="toudijianli" class="btn btn-whtie">投递简历</a>
              <a href="javascript:void(0)" @click="goutong" class="btn btn-whtie">立即沟通</a>
            </div>
          </div>
        </section>
        <section class="section72">
          <div class="content">
            <div class="section72-left">
              <div class="user">
                <div class="left">
                  <a href=""><img :src="recruit.user&&recruit.user.logo?recruit.user.logo:'./images/face.jpg'" alt="" class="face"></a>
                  <h4>{{recruit.user?recruit.user.name:''}}</h4>
                  <p>{{recruit.user?recruit.enterprise.name:''}} | 招聘者 | 刚刚活跃</p>
                </div>
                <div class="right">
                  <a @click="collect" href="javascript:void(0)" class="btns"><img v-if="recruit.collect_count == 0"
                      src="./images/hart.png" alt="" class="icon">
                    <img v-else src="./images/hart-on.png" alt="" class="icon">收藏职位</a>
                  <a class="btns" @click="showReport=true"><img src="images/warn.png" alt="" class="icon">举报</a>
                </div>
              </div>
              <div class="intro">
                <div class="title">职位描述</div>
                <div class="con" v-html="recruit.desc"></div>
              </div>
              <div class="intro">
                <div class="title">技能要求</div>
                <div class="con" v-html="recruit.skill"></div>
              </div>
              <div class="intro">
                <div class="title">团队介绍</div>
                <div class="con" v-html="recruit.intro"></div>
              </div>
              <div class="intro">
                <div class="title">公司地址</div>
                <div class="map-box">
                  <div class="addr">
                    <a>{{recruit.enterprise.addr}}</a>
                  </div>
                  <div class="chart-box">
                    <div id="container"></div>
                    <!-- <img :src="recruit.enterprise.logo" alt="" class="cover"> -->
                  </div>
                </div>
              </div>
            </div>
            <div class="section72-right">
              <div class="user">
                <div class="left">
                  <a @click="link('./08.html?id='+ recruit.enterprise.id)"><img :src="recruit.user&&recruit.user.logo?recruit.user.logo:'./images/face.jpg'" alt="" class="face"></a>
                  <h4>{{recruit.enterprise.name}}</h4>
                  <p>招聘信息{{recruit.enterprise.recruit_count}}条</p>
                </div>
              </div>
  
              <div class="info">
                <div class="item"><img src="images/icon71.png" alt="">{{recruit.enterprise.typeName}}</div>
                <div class="item"><img src="images/icon72.png" alt="">{{recruit.enterprise.sizeName}}</div>
                <div class="item"><img src="images/icon73.png" alt="">{{recruit.enterprise.tradeName}}</div>
              </div>
  
              <div class="intro">
                <div class="title">公司介绍</div>
                <div class="con" v-html="recruit.enterprise.desc"></div>
              </div>
            </div>
          </div>
        </section>
      </template>
    </div>
   
    <footer id="footer"></footer>
    <Report :type='2' :show.sync="showReport" v-if="showReport"></Report>
  </div>
  <script src="js/jquery.min.js"></script>
  <!-- <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script> -->
  <!-- <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script> -->
  <script src="js/common.js"></script>
  <script src="js/lcommon.js"></script>
  <script src="js/slide.min.js"></script>
  <script src="js/polyfill.min.js"></script>
  <script src="js/jquery.nicescroll3.7.6.min.js"></script>
  <!-- <script src="js/main.js"></script> -->
  <script src="js/vue.js"></script>
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  <script src="js/request.js"></script>
  <script src="https://webapi.amap.com/maps?v=1.4.15&key=24688df90aef7762942b8f9b94ba2e70&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>
  <script src="js/moment.min.js"></script>
  <script src="js/moment.locale.js"></script>
  <script src="js/reportComponent.js"></script>
  <script>
    $(function () {
      $("#header").load("./lcommon/header.html");
      $("#footer").load("./lcommon/footer.html");
      $("header .menu li").eq(1).addClass('on')
  })
    var vm = new Vue({
      el: '#app',
      data: {
        loading:false,
        id: GetRequest().id || "",
        recruit: undefined,
        showReport:false
      },
      mounted() {
        var that = this
        indexprepare(function (data) {
          that.getRecruit(data)
        })
      },
      methods: {
        link(url){
          location.href=url
        },
        getNameList(id, list, result=[]) {
          var nameKey = 'region_name'
          result = result || [];
          var item, val;
          for(var i =0; i< list.length; i++) {
            item = list[i];
            if(item.id === id) {
              result.push(item[nameKey])
              return result;
            }else if(item.children) {
              vm.getNameList(id, item.children, result);
              if(result.length) {
                result.unshift(item[nameKey]);
                return result
              }
            }
          }
          return result;
        },
        getRecruit: function (allData) {
          var vm = this
          var url = "person/recruit/" + this.id
          var p = {

          }
          request(url, 'GET', JSON.stringify({}), function (res) {
            vm.loading = false
            var recruit = res.data.recruit
            var addArr = getAreaName(198).reverse().map(function(item){
              return item.name
            })
            recruit.createdFrom = moment(recruit.created_at).fromNow()
            recruit.educationName = getEducationName(recruit.education_id) //教育程度
            recruit.experienceConfigName = getExperienceName(recruit.experience_config_id) //工作年限
            recruit.enterprise.typeName = getTypeName(recruit.enterprise.type_id)
            recruit.enterprise.tradeName = getTradeName(recruit.enterprise.trade_id)
            recruit.enterprise.sizeName = getSizeName(recruit.enterprise.size_id)
            recruit.enterprise.addr = addArr.join('')+recruit.enterprise.address
            recruit.recruit_welfare.forEach(function (m) {
              m.welfareName = getWelfareName(m.welfare_id) //岗位福利
            })
            vm.recruit = recruit
            vm.$nextTick(function(){
            setTimeout(function(){
              var map = new AMap.Map('container', {
                resizeEnable: true,
                zoom: 12,
                center: recruit.enterprise.location
              });
                  // 创建两个点标记
              var m1 = new AMap.Marker({
                position: recruit.enterprise.location
              });
              map.add(m1);
            },1000)
          })
          }, function (err) {
            vm.loading = false
            vm.$message.error(err.responseJSON.message);
          })
        },
        report() {
          var vm = this
          var url = "person/recruit/report"
          var p = {
            id: this.id,
            type: "",
            content: "",
            image: [""]
          }
          request(url, 'POST', JSON.stringify(p), function (res) {
            vm.$message.success(res.message);
          }, function (err) {
            vm.$message.error(err.responseJSON.message);
          })
        },
        collect() {
          var vm = this
          var isLogin = lcheckLogin(vm)
          if (!isLogin) {
            return
          }
          if (vm.recruit.collect_count == 0) {
            var url = "person/user/collect"
            var p = {
              id: this.id
            }
            request(url, 'POST', JSON.stringify(p), function (res) {
              vm.recruit.collect_count = 1;
              vm.$message.success(res.message);
            }, function (err) {
              vm.$message.error(err.responseJSON.message);
            })
          } else {
            var url = "person/user/collect/" + this.id
            request(url, 'DELETE', JSON.stringify(p), function (res) {
              vm.recruit.collect_count = 0;
              vm.$message.success(res.message);
            }, function (err) {
              vm.$message.error(err.responseJSON.message);
            })
          }
        },
        goutong() {
          var vm = this
          var isLogin = lcheckLogin(vm)
          if (!isLogin) {
            return
          }
          location.href = '05.html?uid=' + this.recruit.user.uid
        },
        toudijianli() {
          var vm = this
          var isLogin = lcheckLogin(vm)
          if (!isLogin) {
            return
          }
          var url = "person/recruit/send"
          var p = {
            id: this.recruit.uid,
          }
          request(url, 'POST', JSON.stringify(p), function (res) {
            if (res.code == 1) {
              vm.$message.success("投递成功");
            } else {
              vm.$message.error(res.message);
            }
          }, function (err) {
            vm.$message.error(err.responseJSON.message);
          })
        },
        getNatureName(){
          return getNatureName(this.recruit.type)
        }
      },
    })
  </script>
</body>

</html>